<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>兑换-银酒币</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<include file="public/comm" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav white fs_xl">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left fs_xxi"></a>
			<h1 class="mui-title fs_xl">兑换</h1>
			<a href="{:U('Mobile/User/silver_exchange_detail')}" class="mui-pull-right fs_xl"><span class="fs_m">兑换记录</span></a>
		</header>
		<include file="public/bottom_nav" />
		<div class="mui-content fs_xl">
			<div class="yjb_t mui-input-row fs_xl cls">
				<label class="fs_xl">银酒币</label>
				<input class="mui-input-clear" type="text" name="pay_points" id="yjb_num" value="" placeholder="您当前最多可兑换{$user.pay_points|floor}个" onkeyup="(this.v=function(){this.value=this.value.replace(/[^\d.]/g,'');}).call(this);if(this.value>{$user.pay_points|floor}){this.value={$user.pay_points|floor};}" onblur="this.v();" />
			</div>
			<div class="yjb_bg_img"><img src="__STATIC__/images/sxjt.png" /></div>
			<div class="yjb_t mui-input-row fs_xl cls">
				<label class="fs_xl">金酒币</label>
				<input readonly="readonly" type="text" name="pay_gold" id="jjb_num" value="" />
			</div>
			<div class="tx_ye_btn">
				<a class="ye_btn fs_xl exchange">确认兑换</a>
			</div>
		</div>
		<script type="text/javascript">
			mui.init();
			$(function(){
				var text = document.getElementById("yjb_num");
				text.onkeyup = function() {
					this.value = this.value.replace(/\D/g, '');
					if(text.value > {$user.pay_points|floor}) {
						text.value = {$user.pay_points|floor};
					}
				}
				$("#yjb_num").blur(function(){
					var yjbNum=$(this).val()/100;
					$("#jjb_num").val(yjbNum);
				});
				var inVal=$(".mui-input-clear").val();
				if(inVal==""){
					$(".ye_btn").addClass("active");
				}
				$("input").blur(function(){
					var inVal=$(".mui-input-clear").val();
					if(inVal==""){
						$(".ye_btn").addClass("active");
					}else{
						$(".ye_btn").removeClass("active");
					}
				})
				
				$(".exchange").click(function(){
					var pay_points = $("input[name=pay_points]").val();
					var pay_gold = $("input[name=pay_gold]").val();
					$.post("{:U('Mobile/User/silver_exchange')}",{'pay_points':pay_points,'pay_gold':pay_gold},function(msg){
						if(msg.status == 1){
							layer.alert(msg.msg,1);
							location.href = msg.data.url;
						}
						else{
							layer.alert(msg.msg,2);
						}
					},'json');
				})
			})
		</script>
	</body>

</html>